package com.sankuai.controller;

import com.alibaba.fastjson.JSON;
import com.sankuai.annotaion.CheckParam;
import com.sankuai.model.RegistryParam;
import com.sankuai.model.ResultBean;
import com.sankuai.model.User;
import com.sankuai.service.ExcuterService;
import com.sankuai.utils.JsonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @Author：YH
 * @Description：
 * @Date:Created in 2022/1/15 14:14
 */
@Controller
public class MavenTest {

    @Resource
    private ExcuterService excuterService;

    @GetMapping(value = "/test")
    @ResponseBody
    public String getMessage() {
        excuterService.excute();
        return "Project YES";
    }

    @RequestMapping(value = "update")
    @ResponseBody
    public ResultBean update(@CheckParam User user) {
        return ResultBean.respinseSuccess();
    }

    public static void main(String[] args) {
        User user = new User("LiMing", 1);
        String jsonObject = JsonUtil.objectToJson(user);

        User user1 = JsonUtil.jsonToPojo(jsonObject, User.class);
        String jsonString = JSON.toJSONString(user);
        System.out.println(jsonString);

        RegistryParam registryParam = new RegistryParam("EXECUTOR",
                "xxl-job-executor-sample", "http: //192.168.56.1:9998/");

        String json = JsonUtil.objectToJson(registryParam);
        System.out.println(json);


    }
}
